import * as types from '../mutation-types.js'

const state = {
	added:[]
}

const mutations = {
	[types.ADD_TO_CART](state,{ pid }){
		const record = state.added.find(p => p.pid === pid)
		if (!record ) {
			state.added.push({
				pid:pid,
				count: 1
			})
		} else{
			record.count++
		}
	}
}


export default {
	state,
	mutations
}
